package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.R;
import com.gxa.pojo.Worksheet;
import com.gxa.service.WorksheetService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/WorkSheet")
@Api(value = "工作记录数据test",tags = "工作记录数据接口API-周军国")
public class WorkSheetController {
    @Autowired
    private WorksheetService worksheetService;
    @RequestMapping(value = "/addWorkSheet",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "添加工作记录接口",notes = "向数据库添加工单的工作记录信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R addWorkSheet(@RequestBody@ApiParam(name = "worksheet",value = "添加工单的工作记录",required = true) Worksheet worksheet){
        R r=new R();
        r=worksheetService.addWorkSheet(worksheet);
        return r;
    }
    @RequestMapping(value = "/queryWorkSheetList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询工作记录接口",notes = "向数据库添加工单的工作记录信息",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "repair_id",value = "工作记录的所属工单id",dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public JsonResult queryWorkSheetList(Integer repair_id){
        JsonResult r=new JsonResult();
        r=worksheetService.queryWorkSheetList(repair_id);
        return r;
    }
    @RequestMapping(value = "/deleteWorkSheet",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除工作记录接口",notes = "删除数据库中的工作记录信息",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "worksheetid",value = "工作记录的id",dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteWorkSheet(Integer worksheetid){
        R r=new R();
        r=worksheetService.deleteWorkSheet(worksheetid);
        return r;
    }
    @RequestMapping(value = "/updateWorkSheet",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "更新工作记录接口",notes = "删除数据库中的工作记录信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateWorkSheet(@RequestBody@ApiParam(name = "worksheet",value = "更新工单的工作记录",required = true)Worksheet worksheet){
        R r=new R();
        r=worksheetService.updateWorkSheet(worksheet);
        return r;
    }
}
